Skip to content

Support PEP440 Post-Releases in SemVer.ps1#14495

Open
JennyPng wants to merge 16 commits intoAzure:mainfrom
JennyPng:semver-postrelease
Open

Support PEP440 Post-Releases in SemVer.ps1#14495
JennyPng wants to merge 16 commits intoAzure:mainfrom
JennyPng:semver-postrelease

Conversation

@JennyPng
Copy link
Member

@JennyPng JennyPng commented Mar 12, 2026

Closes #5916

  • support PEP440 post-release version formats for Python https://peps.python.org/pep-0440/#post-releases
  • adds a new PYTHON_SEMVER_REGEX which is conditionally used when the language is Python. Regex validation: https://regex101.com/r/rAdOg0/2 . Post-release handling logic is placed in the constructor of the AzureEngSemanticVersion class
  • adds pester test file for SemVer to test post-release logic. Also added some quick tests

Known downstream consumers of SemVer :

  • SDIST_SEMVER_REGEX in artifact-metadata-parsing.ps1 is only used by Python's Language-Settings in Get-python-PackageInfoFromPackageFile to match the package name - directly modifying this shouldn't affect other languages
  • eng/common/scripts/Update-DevOps-Release-WorkItem.ps1 constructs semver to check VersionType - should be fine, since the constructor is where post-release parsing is handled
  • ChangeLog-Operations used the SEMVER_REGEX to construct a release title match and get entries from the changelog - this was updated to conditionally use the Python version. Pester tests were added
  • copy-docs-to-blobstorage.ps1 had an identical copy of the SEMVER_REGEX to parse prerelease metadata and sort - I refactored this to use SemVer because it seemed redundant, and added tests
  • parseSemverVersionString.ts - seems to be a rewrite of SemVer.ps1 but in TypeScript. Edited this and its tests to model after changes made to SemVer

Questions

  • python-version-check - has its own regex to extract version from changelog and used in apistub's CI for validation, but the current regex doesn't even support pre-release, so unsure if this needs to account for post-release

@JennyPng JennyPng marked this pull request as ready for review March 13, 2026 21:14
@JennyPng JennyPng requested review from a team, chidozieononiwu and raych1 as code owners March 13, 2026 21:15
Copilot AI review requested due to automatic review settings March 13, 2026 21:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Python PEP 440 post-release (.postN) support to the shared SemVer parsing/sorting logic used across eng scripts, and mirrors that behavior in the TypeScript semver parser used by spec-gen-sdk.

Changes:

  • Extend AzureEngSemanticVersion (PowerShell) to recognize/normalize/sort Python post-releases and update changelog parsing to use a Python-aware title regex when $Language == "python".
  • Refactor copy-docs-to-blobstorage.ps1 to reuse AzureEngSemanticVersion rather than maintaining a separate semver regex/sort implementation.
  • Update the TypeScript parseSemverVersionString implementation + tests to support post-releases; add/extend Pester tests for SemVer, changelog parsing, and docs version sorting.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tools/spec-gen-sdk/src/utils/parseSemverVersionString.ts Add Python-specific regex/logic for PEP 440 post-releases and return post-release metadata.
tools/spec-gen-sdk/test/utils/parseSemverVersionString.test.ts Add Vitest coverage for Python post-release parsing and non-Python behavior.
eng/common/scripts/SemVer.ps1 Add PYTHON_SEMVER_REGEX and post-release parsing/normalization/sorting in AzureEngSemanticVersion.
eng/common/scripts/ChangeLog-Operations.ps1 Use Python-aware release title regex when $Language indicates Python.
eng/common/scripts/copy-docs-to-blobstorage.ps1 Replace local semver regex parsing with AzureEngSemanticVersion and rely on its comparer for sorting.
eng/common/scripts/artifact-metadata-parsing.ps1 Update SDist filename parsing regex to allow Python post-releases.
eng/scripts/python_version_check.py Extend version extraction to allow .postN versions.
eng/common-tests/SemVer.Tests.ps1 Add Pester coverage for post-release parsing/normalization/sorting/increment behavior.
eng/common-tests/ChangeLog-Operations.Tests.ps1 Add Pester coverage for parsing/sorting changelogs containing post-releases.
eng/common-tests/copy-docs-to-blobstorage.Tests.ps1 Add Pester coverage for docs version parsing/sorting with post-releases.

You can also share your feedback on Copilot code review. Take the survey.

@scbedd
Copy link
Member

scbedd commented Mar 13, 2026

/azp run tools - sync-eng-common

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update SemVer to honor python post releases

4 participants